Functions for specifying randomly generated values
The following functions are available for specifying randomly generated values. You can enter these functions and their values in the Min and Max fields of the variable definition table or in an answer box.
Function | Format | Purpose | Example |
---|---|---|---|
rand |
rand(range-start,range-end,exponent) | Generates a random number within a specified range, optionally rounded to a specific power of 10. | rand(10,100,1) randomly returns 10, 20, 30, ...100. The default value for exponent is 0; that is, the value returned is rounded to the nearest integer. |
round |
round(value,exponent) | Rounds a value to a specific power of 10. | round(1.2345,-3) returns 1.235. |
sigdig |
sigdig(value,exponent) |
Rounds a value to a specific number of significant digits. | sigdig(1.2345,3) returns 1.23. |
ifthenelse | ifthenelse(test,true_value,false_value) | Returns one of two values depending on the result of a logical test. | ifthenelse(x>y,x,y) returns x if x is larger; otherwise it returns y. |
ifthenelse function example
Variable | Description |
---|---|
y |
ifthenelse is used to produce the value 1 or 0 based on the value of x. If x is a number between 6 and 10, the value 1 is returned. If x is a number between 1 and 5, the value 0 is returned. |
round function example
These variables are in an item to calculate the total energy required to convert a solid to a gas using heat capacity, heat of fusion, and heat of vaporization.
Variable | Description |
---|---|
q_1 |
|
|
|
q_3 |
|
See also: